const fixDuration = (audio, callback) => {
    audio.addEventListener('loadedmetadata', () => {
        // Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=642012
        if (audio.duration === Infinity) {
            audio.currentTime = Number.MAX_SAFE_INTEGER;
            audio.ontimeupdate = () => {
                audio.ontimeupdate = null;
                if (callback) callback(audio.duration);
                // 只设置一次没法到初始
                audio.currentTime = 0.1;
                audio.currentTime = 0;
            };
        }
    });
};

export { fixDuration };
